2026-09-22 · class-notes, tryhackme, networking, osi-model, tcp, udp
Full class notes for TryHackMe Pre Security (2026 path) module 5, OSI Model: the seven layers, what each one does, TCP versus UDP, and encapsulation.
Class notes · TryHackMe Pre Security (2026 path) · Module 5, room 3: OSI Model
Quick reference: the short version of this room is the OSI Model cheat sheet, the third sheet in Module 5, after What is Networking? and Intro to LAN. Networking for Sysadmins chapter 1 covers the same layers from a working sysadmin's point of view.
By the end of these notes you should be able to:
The OSI model (Open Systems Interconnection model) is a framework that describes how networked devices send, receive and interpret data. It splits the whole job into seven layers, each with its own responsibilities, numbered from 7 at the top down to 1 at the bottom.
Its main benefit is interoperability. Devices can be built by different manufacturers, run different software and do completely different jobs, yet still understand each other, because they all follow the same layered rules. A network card from one company works with a switch from another and a web server from a third.
As data travels down the layers, each one adds its own piece of information to it. That process is encapsulation, and section 9 follows it end to end.
+---+--------------+-----------------------------------+---------+
| 7 | Application | HTTP, DNS, SMTP, FTP | Data |
| 6 | Presentation | Formats, encoding, encryption | Data |
| 5 | Session | Opens, maintains, closes sessions | Data |
+---+--------------+-----------------------------------+---------+
| 4 | Transport | TCP and UDP, port numbers | Segment |
| 3 | Network | IP addresses, routers | Packet |
| 2 | Data link | MAC addresses, switches | Frame |
| 1 | Physical | Cables, signals, bits | Bits |
+---+--------------+-----------------------------------+---------+
Exam tip: two common mnemonics. Bottom-up (1 to 7): "Please Do Not Throw Sausage Pizza Away". Top-down (7 to 1): "All People Seem To Need Data Processing".
The physical layer is the hardware itself: cables, connectors and the signals travelling along them. Devices send data to each other as electrical signals (or light, or radio waves) representing the binary ones and zeros underneath everything else.
An Ethernet cable between two devices is a physical layer component. So is the socket it plugs into, and the signal running through it.
The data link layer deals with physical addressing. It takes the packet handed down by the network layer, which carries the IP address of the destination computer, and adds the MAC address (Media Access Control address) of the interface the data should be delivered to. It also presents the data in a form suitable for transmission on the medium below.
Every network-enabled computer has a network interface card (NIC) with its own MAC address to identify it.
Correction: the room says MAC addresses are "literally burnt into the card; they can't be changed – although they can be spoofed", which contradicts itself. The address is assigned by the manufacturer and stored on the card, but the operating system can override the address it uses, in one command. Spoofing is changing it, as far as the network can tell. Many phones and laptops now use a randomised MAC address on Wi-Fi by default.
Note (beyond this lesson): the MAC address added here is that of the next device on the way, not the final destination. If the destination is on another network, the frame is addressed to the router, which strips it off and builds a new frame for the next hop. MAC addresses are local to each link; the IP address inside stays the same end to end.
The network layer is where routing happens: working out the best path for data to take across networks to reach the destination.
Routing protocols decide what "best" means. Two you should recognise at this stage are OSPF (Open Shortest Path First) and RIP (Routing Information Protocol). The factors they weigh include:
| Factor | Question it answers |
|---|---|
| Distance | Which path crosses the fewest devices? |
| Reliability | Has this path lost packets before? |
| Speed | Is this link copper (slower) or fibre (much faster)? |
Everything at this layer is addressed by IP address, such as 192.168.1.100. Devices that can deliver packets using IP addresses, routers above all, are called layer 3 devices, because they work at the third layer of the model.
Correction: the room describes the network layer as handling "re-assembly of data (from these small chunks to the larger chunk)". Splitting data into chunks and putting them back in order is the transport layer's job (section 5). The network layer can split an oversized packet into fragments and the destination reassembles those, but the chunking the room is describing belongs one layer up.
Note (beyond this lesson): the protocols differ in how they measure a path. RIP simply counts hops, so it treats a slow link the same as a fast one. OSPF works out a cost based on bandwidth, which is why it is the one used inside serious networks.
The transport layer moves data between devices using one of two protocols, chosen to suit the job: TCP or UDP.
TCP (Transmission Control Protocol) is built for reliability. It establishes a connection between the two devices and keeps it for as long as the exchange lasts. It also includes error checking, which is how it can guarantee that the chunks it sent arrive and are reassembled in the right order.
| Advantages of TCP | Disadvantages of TCP |
|---|---|
| Guarantees the data is accurate and complete | Needs a working connection between both devices throughout |
| Can pace the sender so the receiver isn't flooded | A slow connection holds resources open on the other device |
| Does the extra work of acknowledging and re-sending | Slower than UDP, because of all that extra work |
TCP suits file sharing, web browsing and email: anything where the data has to arrive complete and in order. Half a file is no use to anyone.
Correction: the room says TCP "reserves a constant connection", and that if one chunk is not received, the whole thing cannot be used. Both overstate it. A TCP connection is a logical agreement between the two ends, not reserved capacity on the network; nothing in between is set aside. And a missing chunk is simply re-sent: TCP notices the gap and retransmits, so the application waits a little rather than losing the data.
UDP (User Datagram Protocol) does far less. There is no connection, no error checking and no guarantee: data is sent whether or not it arrives.
| Advantages of UDP | Disadvantages of UDP |
|---|---|
| Much faster, with far less overhead | No check that anything arrived |
| Leaves the application in control of how fast to send | Unstable connections give a poor experience |
| Holds no continuous connection on either device | The application has to cope with loss itself |
TCP: numbered, acknowledged, anything missing is re-sent
sent [1][2][3][4] -> received [1][2][3][4] whole picture
UDP: sent once, with no check that it arrived
sent [1][2][3][4] -> received [1][ ][3][ ] gaps stay gaps
UDP suits small exchanges and real-time traffic, where a late packet is worth less than a missing one. Live video is the classic case: a few lost pixels matter less than the picture stopping to wait.
Correction: the room gives ARP and DHCP as examples of UDP protocols. DHCP does use UDP, but ARP does not. ARP works at layer 2, below IP entirely, so it has no ports and no UDP header. Other genuine UDP examples are DNS queries, NTP and VoIP.
Note (beyond this lesson): on-demand video, such as a streaming service or a video site, is usually delivered over TCP or over QUIC (which adds reliability on top of UDP). It is live and interactive traffic, like video calls, that most benefits from plain UDP.
For each case, decide which protocol fits and why.
The rule of thumb: if losing a piece breaks the result, use TCP. If being slow breaks the result, use UDP.
Once the layer above has formatted the data, the session layer creates and maintains the connection to the other computer. While that connection is alive, it is a session.
The session layer also closes connections that have been unused for a while or have been lost, and it can place checkpoints in a transfer. If something goes wrong, only the data after the last checkpoint needs sending again, which saves bandwidth.
Sessions are separate from each other: data belongs to one session and does not cross into another.
The presentation layer is where standardisation happens. Software developers can build an email client (or anything else) however they like, but the data still has to be handled in a way everyone agrees on, so it acts as a translator between the application layer above and the rest of the stack.
That is why you can send an email from one client and have it display correctly in a completely different one. Character encoding, file formats and compression sit here, and so does encryption, such as the HTTPS that protects a secure website.
Note (beyond this lesson): TLS, the encryption behind HTTPS, is usually taught as a presentation-layer job, but it doesn't fit the model cleanly: it sits between the application and transport layers and is often described as spanning layers 5 and 6. The OSI model is a map, not a rulebook.
The application layer is the one you see. It holds the protocols and rules that decide how the user interacts with data being sent and received. Email clients, browsers and file transfer software such as FileZilla give you a graphical interface on top of it, and protocols such as DNS (which turns website names into IP addresses), HTTP, SMTP and FTP live here.
Note (beyond this lesson): strictly, the application layer is the protocols, not the program's buttons and menus. The browser window is software; HTTP and DNS are what layer 7 defines.
Every layer adds its own header as data travels down the stack, and the receiving device strips them off on the way up. The unit of data gets a different name at each stage.
DOWN the stack (sender) UP the stack (receiver)
7-5 the application's data data handed to the application
4 + TCP or UDP header = segment transport header removed
3 + IP header = packet IP header removed
2 + MAC header/trailer = frame frame header and trailer removed
1 sent as bits --------------> bits read back in
Adding the headers is encapsulation; stripping them is decapsulation.
| Layer | Unit of data | Header added |
|---|---|---|
| 7 to 5 | Data | The application's own formatting |
| 4 Transport | Segment (TCP) or datagram (UDP) | Port numbers, sequence numbers |
| 3 Network | Packet | Source and destination IP addresses |
| 2 Data link | Frame | Source and destination MAC addresses, plus a trailer for error checking |
| 1 Physical | Bits | None: the frame becomes signals |
You type an address into a browser and press Enter.
Matching a symptom to a layer tells you where to look next.
| What you see | Layer | Why |
|---|---|---|
| No link light on the switch port | 1 | No signal on the cable |
| Two devices claiming one IP address | 2 and 3 | The IP address clashes; ARP exposes it |
| Can ping the server but not connect to port 443 | 4 | Layers 1 to 3 work; the transport layer or a firewall is blocking |
| The site loads by IP address but not by name | 7 | DNS is an application layer protocol |
| Certificate warning in the browser | 6 (in OSI terms) | Encryption and formatting sit here |
| Term | Meaning |
|---|---|
| Decapsulation | Stripping each layer's header off as data travels up the stack |
| Encapsulation | Adding each layer's header as data travels down the stack |
| Frame | The unit of data at layer 2, addressed by MAC address |
| Layer 3 device | A device such as a router that forwards using IP addresses |
| MAC address | The hardware address of a network interface |
| NIC | Network interface card: the hardware that connects a device to the network |
| OSI model | A seven-layer framework describing how devices communicate |
| OSPF | Open Shortest Path First: a routing protocol that costs paths by bandwidth |
| Packet | The unit of data at layer 3, addressed by IP address |
| RIP | Routing Information Protocol: an older routing protocol that counts hops |
| Routing | Choosing the path data takes across networks |
| Segment | The unit of data at layer 4 when TCP is used |
| Session | An active connection between two devices, created at layer 5 |
| Checkpoint | A marker in a transfer so only newer data need be re-sent |
| TCP | Transmission Control Protocol: connection-oriented and reliable |
| UDP | User Datagram Protocol: fast, connectionless and unguaranteed |